<template>
  <div class="recommend-blog-group">
    <div class="top">
      <div class="title">推荐博客</div>
      <i class="el-icon-refresh" @click="getRecommend('1')"/>
    </div>

    <div v-if="!list || list.size == 0">
      <div v-for="(item, index) in async_list" :key="index">
        <blog-list-item :item="item" />
      </div>
    </div>

    <div v-else>
      <div v-for="(item, index) in list" :key="index">
        <blog-list-item :item="item" />
      </div>
    </div>

    <div class="show-in-pc">
      <list-end v-if="list && list.length > 0"/>
    </div>
  </div>
</template>

<script>
import Api from"@/utils/api.js"
import BlogListItem from './BlogListItem.vue';
import ListEnd from '@/components/ListEnd.vue';
export default {

  props: ["async_list"],

  data(){
    return {
      list: ''
    }
  },

  components:{
    BlogListItem,
    ListEnd
  },
  
  methods: {
    getRecommend(refresh){
      this.$axios.post(Api.RECOMMEND_BLOG, {refresh : refresh}).then(res => {
        this.list = res
      }).catch(res => {
        this.$message.warning(res.message);
      })
    }
  }
}
</script>

<style lang="less" scoped>
@import '@/assets/css/index.less';

.recommend-blog-group {
  font-size: 18px;
  height: 100%;
  width: 100%;

  .top{
    padding: 10px;
    .flex-center-between();

    .title{
      font-size: 14px;
      font-weight: 500;
      color: #353535;
    }

    .value{
      font-size: 12px;
      color: #999999;
    }

    .el-icon-refresh{
      font-size: 15px;
      color: #999999;
      cursor: pointer;
    }
  }

  .item{
    padding: 10px;
    cursor: pointer;
    .flex();

    &:hover{
      background-color:#edf0f5;
    }

    .item-right-box{
      height: 36px;
      .flex-start-between();
      flex-direction: column;

      .user-name{
        font-size: 12px;
        font-weight: 500;
        color: #333333;
        margin-left: 10px;
      }

      .user-info{
        font-size: 12px;
        color: #999999;
        margin-left: 10px;
        .flex-center-start();

        .item-status-dot{
          height: 3px;
          width: 3px;
          border-radius: 50%;
          background-color: #555666;
          margin: 0 8px;
        }
      }      
    }
  }
}
</style>
